﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using prjKQXS_UI.Danh_muc;
using prjKQXS_UI.Hop_dong;
using prjKQXS_UI.Truyen_thong;
using prjKQXS_UI.Lo_to;
using prjKQXS_UI.Security;
using prjKQXS_DLL;

namespace prjKQXS_UI.View
{
    public partial class frmMetro : DevExpress.XtraEditors.XtraForm
    {
        public frmMetro()
        {
            InitializeComponent();
        }

        frmMain frmMain = null;
        public frmMetro(frmMain frmMain)
        {
            InitializeComponent();
            this.frmMain = frmMain;
        }

        SqlConnection conn = new SqlConnection(BienTc.connString);
        private void loadData()
        {
            try
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                SqlDataAdapter da = null;
                DataTable dt= null;

                da = new SqlDataAdapter("Select Sum(Doanh_Thu) from Doanhthu Where isPublic=1", conn);
                dt = new DataTable();
                da.Fill(dt);

                
            }
            catch (Exception)
            {
                
            }
        }

        private void frmMetro_Load(object sender, EventArgs e)
        {
            //if (!clsCommon.hasPermission(BienTc.UserID, (int)BienTc.eFunction.T_tileHopdong))
            //{
            //    tileHopdong.Enabled = true;
            //}       
        }

        private void tileItem1_ItemClick(object sender, TileItemEventArgs e)
        {
            frmDMHopDong frm = new frmDMHopDong();
            frm.MdiParent = frmMain;
            frm.WindowState = FormWindowState.Maximized;
            frm.Show();
        }

        private void tileItem3_ItemClick(object sender, TileItemEventArgs e)
        {
            frmDMDonVi frm = new frmDMDonVi();
            frm.MdiParent = frmMain;
            frm.WindowState = FormWindowState.Maximized;
            frm.Show();
        }

        private void tileItem6_ItemClick(object sender, TileItemEventArgs e)
        {
            frmHoaHongCFG frm = new frmHoaHongCFG();
            frm.ShowDialog();
        }

        private bool checkForm(string frmName)
        {
            bool retVal = false;
            if (Application.OpenForms[frmName] == null)
            {
                retVal = true;
            }
            return retVal;
        }

        private void tileThoat_ItemClick(object sender, TileItemEventArgs e)
        {
            Application.Exit();
        }

        private void tilehopdong_ItemClick(object sender, TileItemEventArgs e)
        {
            frmUpdateDL frm = new frmUpdateDL();
            frm.Show();
        }
        private void tileHopdong_ItemClick_1(object sender, TileItemEventArgs e)
        {
            frmDMHopDong frm = new frmDMHopDong();
            frm.WindowState = FormWindowState.Maximized;
            frm.ShowDialog();
        }

        private void tiNhatKyQuy_ItemClick(object sender, TileItemEventArgs e)
        {
            frmMain.bbiNhatKyQuy_ItemClick(sender, null);
        }

        private void tileHoaHongDL_ItemClick(object sender, TileItemEventArgs e)
        {
            frmMain.bbiNhapDoanhThuDaiLy_ItemClick(sender, null);
        }

        private void tileLoTo_ItemClick(object sender, TileItemEventArgs e)
        {
            frmMain.bbiNhapSoDuThuongLoTo_ItemClick(sender, null);
        }

        private void tileTruyenThong_ItemClick(object sender, TileItemEventArgs e)
        {
            frmMain.bbiNhapVeHuy_ItemClick(sender, null);
        }

        private void frmMetro_Shown(object sender, EventArgs e)
        {
            //if (!clsCommon.hasPermission(BienTc.UserID, (int)BienTc.eFunction.T_tileHopdong))
            //{
            //    tileHopdong.Enabled = false;
            //}
            //tileHopdong.Enabled = !clsCommon.hasPermission(BienTc.UserID, (int)BienTc.eFunction.M_tileHopdong);
            //tiNhatKyQuy.Enabled = clsCommon.hasPermission(BienTc.UserID, (int) BienTc.eFunction.M_tiNhatKyQuy);
        }
        
        }
}